const bcrypt = require("bcrypt");

const encryptPassword = async (password) => {
  const saltRounds = 10; // 你可以根据需要调整盐值轮次
  const salt = await bcrypt.genSalt(saltRounds);
  const hash = await bcrypt.hash(password, salt);
  return hash;
};

const decodePassword = (password, user) =>
  bcrypt.compare(password, user.passwordHash);

module.exports = {
  encryptPassword,
  decodePassword,
};
